package com.xmy.cultivate.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xmy.cultivate.entity.*;
import com.xmy.cultivate.entity.views.GradeStudent;
import com.xmy.cultivate.entity.views.OrderDetailTiny;
import com.xmy.cultivate.entity.views.SelectStudent;
import com.xmy.cultivate.exception.CommonException;
import com.xmy.cultivate.feign.english.IFeiEnglishFeignClient;
import com.xmy.cultivate.mapper.*;
import com.xmy.cultivate.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xmy.cultivate.util.IdWorker;
import com.xmy.cultivate.util.ResultCode;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.sql.Struct;
import java.util.*;

/**
 * <p>
 * 学生表 服务实现类
 * </p>
 *
 * @author min
 * @since 2022-07-26
 */
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements IStudentService {

    @Autowired
    IdWorker idWorker;

    @Autowired
    @Lazy
    StudentMapper studentMapper;

    @Autowired
    @Lazy
    DictMapper dictMapper;

    @Autowired
    @Lazy
    ITypeValueDataService iTypeValueDataService;

    @Autowired
    @Lazy
    OrderDetailMapper orderDetailMapper;

    @Autowired
    @Lazy
    GradeMapper gradeMapper;

    @Autowired
    @Lazy
    IStudentGradeService iStudentGradeService;

    @Autowired
    @Lazy
    CourseMapper courseMapper;

    @Autowired
    @Lazy
    StudentGradeMapper studentGradeMapper;

    @Autowired
    @Lazy
    IStudentSchoolService iStudentSchoolService;

    @Autowired
    @Lazy
    IStudentFaceDataService iStudentFaceDataService;

    @Autowired
    @Lazy
    IQuarterService iQuarterService;

    @Autowired
    @Lazy
    IDictService iDictService;

    @Autowired
    @Lazy
    IOrderDetailService iOrderDetailService;

    @Autowired
    @Lazy
    IStudentClassTypeService iStudentClassTypeService;

    @Autowired
    @Lazy
    ITranscriptService iTranscriptService;

    @Autowired
    @Lazy
    ICourseTypeService iCourseTypeService;

    @Autowired
    @Lazy
    IGradeService iGradeService;

    @Autowired
    @Lazy
    IFeiEnglishFeignClient iFeiEnglishFeignClient;

    public IPage<Student> findAll(IPage<?> page, Wrapper wrapper,Long schoolId){

        IPage<Student> studentIPage = studentMapper.findAll(page,wrapper);
        for (Student student:studentIPage.getRecords()){
            // as b where b.status <> 2 and b.residue_course_count>0 and b.student_id = a.id and a.deleted=0
            QueryWrapper<Student> studentQueryWrapper = new QueryWrapper<>();
            studentQueryWrapper.ne("status",2);
            studentQueryWrapper.eq("deleted",0);
            studentQueryWrapper.gt("residue_course_count",0);
            studentQueryWrapper.eq("student_id",student.getId());
            Integer count = studentMapper.getApplyCourseCount(studentQueryWrapper);
            if(schoolId.equals(0L)){
                schoolId = student.getSchoolId();
            }
            if(iStudentFaceDataService.isGather(schoolId,student.getId())){
                student.setIsGather(1);
            }else {
                student.setIsGather(0);
            }
            student.setApplyCourseCount(count);
        }

        return studentIPage;
    }

    public IPage<Student> rosterList(IPage<?> page, Wrapper wrapper,Long schoolId){

        IPage<Student> studentIPage = studentMapper.rosterList(page,wrapper);

        for (Student student:studentIPage.getRecords()){
            if(schoolId.equals(0L)){
                schoolId = student.getSchoolId();
            }
            if(iStudentFaceDataService.isGather(schoolId,student.getId())){
                student.setIsGather(1);
            }else {
                student.setIsGather(0);
            }
        }
        return studentIPage;
    }

    /**
     * 获取欠费
     * @param wrapper
     * @return
     */
    public BigDecimal arrearage(Wrapper wrapper){
        return studentMapper.arrearage(wrapper);
    }

    public IPage<Student> signUpStu(IPage<?> page, Wrapper wrapper){
        return this.signUpStu(page,wrapper);
    }

    public Student findOne(@Param("id") Long id){

        Student student = studentMapper.findOne(id);
        QueryWrapper<TypeValueData> typeValueDataQueryWrapper = new QueryWrapper<>();
        typeValueDataQueryWrapper.eq("for_id",student.getId());
        typeValueDataQueryWrapper.eq("type",4);
        List<TypeValueData> typeValueList = iTypeValueDataService.list(typeValueDataQueryWrapper);
        student.setLinkManList(typeValueList);
        return student;
    }

    public Boolean saveTo(Student student){

        student.setId(idWorker.nextId());

        List<TypeValueData> typeValueDataList = new ArrayList<>();

        Iterator<TypeValueData> iterator = student.getLinkManList().iterator();
        Integer i = 0;
        while (iterator.hasNext()){
            TypeValueData typeValueData = iterator.next();
            if(typeValueData.getTypeId()!= null) {
                typeValueData.setForId(student.getId());
                typeValueData.setType(4);
                typeValueDataList.add(typeValueData);
                if(i==0){
                    QueryWrapper<Dict> queryWrapper =  new QueryWrapper<>();
                    queryWrapper.eq("num",typeValueData.getTypeId());
                    queryWrapper.eq("type",4);
                    Dict dict = dictMapper.selectOne(queryWrapper);
                    if(dict != null){
                        student.setLinkman(dict.getName());
                        student.setLinkmanPhone(typeValueData.getContent());
                    }
                }
                i++;
            }
        }

        if(typeValueDataList.size()>0){
            iTypeValueDataService.saveBatch(typeValueDataList);
        }
        studentMapper.insert(student);
        iStudentSchoolService.addOrUpdateData(student.getId(),student.getSchoolId());


        return true;
    }

    public boolean updateTo(Student student){
        List<TypeValueData> typeValueDataList = new ArrayList<>();
        List<TypeValueData> upTypeValueDataList = new ArrayList<>();
        Set<Long> atTypeValueData = new HashSet<>();

        Integer i = 0;
        Iterator<TypeValueData> iterator = student.getLinkManList().iterator();
        while (iterator.hasNext()){
            TypeValueData typeValueData = iterator.next();
            if(typeValueData.getTypeId()!=null) {
                if(typeValueData.getId()==0){
                    typeValueData.setId(idWorker.nextId());
                    typeValueData.setForId(student.getId());
                    typeValueData.setType(4);
                    typeValueDataList.add(typeValueData);
                }else{
                    typeValueData.setForId(student.getId());
                    typeValueData.setType(4);
                    upTypeValueDataList.add(typeValueData);
                    atTypeValueData.add(typeValueData.getId());
                }
                if(i==0){
                    QueryWrapper<Dict> queryWrapper =  new QueryWrapper<>();
                    queryWrapper.eq("num",typeValueData.getTypeId());
                    queryWrapper.eq("type",4);
                    Dict dict = dictMapper.selectOne(queryWrapper);
                    if(dict != null){
                        student.setLinkman(dict.getName());
                        student.setLinkmanPhone(typeValueData.getContent());
                    }
                }
                i++;
            }
        }

        //删除
        if(atTypeValueData.size()>0){
            QueryWrapper<TypeValueData> queryWrapper =  new QueryWrapper<>();
            queryWrapper.notIn("id",atTypeValueData);
            queryWrapper.eq("for_id",student.getId());
            iTypeValueDataService.remove(queryWrapper);
        }
        //新增
        if(typeValueDataList.size()>0){
            iTypeValueDataService.saveBatch(typeValueDataList);
        }
        //修改
        if(upTypeValueDataList.size()>0){
            iTypeValueDataService.updateBatchById(upTypeValueDataList,upTypeValueDataList.size());
        }

        //修改主体
        studentMapper.updateById(student);
        return true;
    }

    public IPage<Student> getStudentForGradeId(Long gradeId,String name,Integer pageNum,Integer pageSize){
        Grade grade = gradeMapper.selectById(gradeId);

        Course course = courseMapper.selectById(grade.getCourseId());

        Integer yearAndQuarter = Integer.parseInt(grade.getYearPart()+""+course.getQuarterNum());

        IPage<Student> iPage = new Page<>(pageNum,pageSize);

        QueryWrapper<StudentGrade> studentGradeQueryWrapper = new QueryWrapper<>();

        //where id in (select b.student_id from student_grade as b where b.grade_id = #{gradeId} and b.status = 1 and deleted = 0 and reading_status<>3)
        studentGradeQueryWrapper.inSql("id","select b.student_id from student_grade as b where b.grade_id = "+gradeId+" and b.status = 1 and deleted = 0 and reading_status in(1,4,5,6)");
        studentGradeQueryWrapper.like(StringUtils.isNotBlank(name),"name",name);


        IPage<Student> studentList = studentMapper.getStudentForGradeId(iPage,studentGradeQueryWrapper);
        for (Student student:studentList.getRecords()){
            //OrderDetailTiny orderDetailTiny =  orderDetailMapper.getResidueCourseCountForCourseId(student.getId(),grade.getCourseId(),grade.getSchoolId());

            if(course!=null){
                Integer allCourseHouse = orderDetailMapper.getAllCouseHouse(grade.getSchoolId(),student.getId(),course.getSubjectsId());

                Integer residueCourseCount = orderDetailMapper.getResidueCourseCountForSubjects(grade.getSchoolId(),student.getId(),course.getSubjectsId(),yearAndQuarter,grade.getLessonType(),course.getYearClassId().getKey());
                student.setResidueCourseCount(residueCourseCount);
                student.setAllCourseCount(allCourseHouse);

                /*QueryWrapper<StudentGrade> studentGradeQueryWrapperForStudent = new QueryWrapper<>();
                studentGradeQueryWrapperForStudent.orderByDesc("created_at");
                studentGradeQueryWrapperForStudent.eq("deleted",0);
                studentGradeQueryWrapperForStudent.eq("grade_id",gradeId);
                studentGradeQueryWrapperForStudent.eq("student_id",student.getId());
                studentGradeQueryWrapperForStudent.ne("status",3);
                studentGradeQueryWrapperForStudent.last("limit 1");
                StudentGrade studentGrade = studentGradeMapper.selectOne(studentGradeQueryWrapperForStudent);*/
                String state = iStudentGradeService.studentAtGradeState(gradeId,student.getId(),1);
                student.setState(state);
                String courseStatus = iStudentGradeService.getCourseStatus(gradeId,student.getId(),1);
                student.setCourseStatus(Integer.parseInt(courseStatus));

            }else {
                student.setResidueCourseCount(0);
                student.setAllCourseCount(0);
            }
            Integer userCourseCount = studentGradeMapper.useCourseCount(grade.getId(),student.getId());
            student.setUseCourseCount(userCourseCount);

            student.setClassId(gradeId);
        }
        return studentList;
    }

    public IPage<SelectStudent> getStudentForShift(IPage<?> page, Wrapper wrapper, Grade grade){

        Course course = courseMapper.selectById(grade.getCourseId());

        IPage<SelectStudent> selectStudentIPage = studentMapper.getStudentForShift(page,wrapper,grade.getSchoolId(),grade.getCourseId(),grade.getYearPart(),course.getQuarterNum());
        for (SelectStudent selectStudent:selectStudentIPage.getRecords()){
            selectStudent.setGradeId(grade.getId());
            //selectStudent.setHandleDate();
            selectStudent.setResidueCourseCount(orderDetailMapper.getResidueCourseHouseForCourseId(selectStudent.getStudentId(),grade.getCourseId(),grade.getSchoolId()));
        }

        return selectStudentIPage;
    }

    public boolean addGradeStudent(String gradeId,String[] studentList){

        Grade grade = gradeMapper.getOneForId(Long.parseLong(gradeId));
        if(grade==null){
            throw new CommonException(ResultCode.GRADE_NOT);
        }
        List<StudentGrade> studentGradeList = new ArrayList<>();
        for (String id:studentList){
            Long studentId = Long.parseLong(id);
            OrderDetail orderDetail = orderDetailMapper.getLastOneForCourseId(grade.getSchoolId(),studentId,grade.getCourseId());
            if(orderDetail != null){
                StudentGrade studentGrade = new StudentGrade();
                studentGrade.setOrderDetailId(orderDetail.getId());
                studentGrade.setStudentId(studentId);
                studentGrade.setSchoolId(grade.getSchoolId());
                studentGrade.setGradeId(grade.getId());
                studentGrade.setCourseId(grade.getCourseId());
                studentGrade.setSubjectsId(orderDetail.getSubjectsId());
                studentGrade.setRenewTeacherId(grade.getTeacherId());
                studentGrade.setYearPart(orderDetail.getYearPart());
                studentGrade.setQuarterNum(orderDetail.getQuarterNum());
                studentGrade.setSurplusCourseNum(orderDetail.getResidueCourseCount());
                studentGrade.setIsRenew(1);
                studentGradeList.add(studentGrade);
            }
        }
        if(studentGradeList.size()>0){
            iStudentGradeService.saveBatch(studentGradeList);
        }
        return true;
    }



    public void updateClassType(){
        Quarter quarter = iQuarterService.getNowQuarter();
        //获取上一个学期
        Quarter lastQuarter = iQuarterService.getLastQuarter(quarter.getYearPart(),quarter.getNum());
        Dict dict = iDictService.getQuarter(lastQuarter.getNum());
        //dict.getTag();//1为假期，0为非假期
        List<OrderDetail> orderDetailList = iOrderDetailService.getOrderDetailForResidueCoruseCount(quarter.getYearPart(),quarter.getNum());
        for (OrderDetail orderDetail:orderDetailList){
            try{
                if (orderDetail.getSubjectsId().equals(1L)){
                    this.updateClassTypeEnglish(orderDetail,dict,quarter,lastQuarter);
                }else if (orderDetail.getSubjectsId().equals(2L)){
                    this.updateClassTypeOther(orderDetail,dict,quarter,lastQuarter);
                }else if (orderDetail.getSubjectsId().equals(3L)){
                    this.updateClassTypeOther(orderDetail,dict,quarter,lastQuarter);
                }
            }catch (Exception e){
            }
        }
    }

    /**
     * 英语
     * @param orderDetail
     * @param dict
     * @param quarterNow
     * @param quarterLast
     */
    public void  updateClassTypeEnglish(OrderDetail orderDetail,Dict dict,Quarter quarterNow,Quarter quarterLast){

        Integer isVacation = dict.getTag();//上个学期是否假期

        //调用学期系统数据
        Map<String,String> map =  iFeiEnglishFeignClient.getStudentClassType(orderDetail.getStudentId(),isVacation,quarterLast.getYearPart(),quarterLast.getNum());

        QueryWrapper<StudentClassType> studentClassTypeQueryWrapper = new QueryWrapper<>();
        studentClassTypeQueryWrapper.eq("student_id",orderDetail.getStudentId());
        studentClassTypeQueryWrapper.eq("subjects_id",orderDetail.getSubjectsId());
        studentClassTypeQueryWrapper.eq("year_part",quarterNow.getYearPart());
        studentClassTypeQueryWrapper.eq("quarter_num",quarterNow.getNum());

        //是否已经添加过
        StudentClassType studentClassType = iStudentClassTypeService.getOne(studentClassTypeQueryWrapper);
        if (studentClassType == null){
            studentClassType = new StudentClassType();
            //iStudentClassTypeService.save(studentClassType);
        }
        studentClassType.setYearPart(quarterNow.getYearPart());
        studentClassType.setQuarterNum(quarterNow.getNum());
        studentClassType.setStudentId(orderDetail.getStudentId());
        studentClassType.setSubjectsId(orderDetail.getSubjectsId());
        studentClassType.setYearClassId(orderDetail.getYearClassId());
        studentClassType.setLastClassTypeId(0L);
        studentClassType.setRemark("");

        if(StringUtils.isNotBlank(map.get("classTypeId")) && StringUtils.isNotBlank(map.get("classTypeIdStr"))){
            Long classTypeId = Long.parseLong(map.get("classTypeId"));
            String classTypeIdStr = map.get("classTypeIdStr");
            studentClassType.setClassTypeId(classTypeId);
            studentClassType.setClassTypeIdStr(classTypeIdStr);
        }else {
            Integer yearPart = quarterLast.getYearPart();
            Integer quarterNum = quarterLast.getNum();
            QueryWrapper<StudentGrade> studentGradeQueryWrapper = new QueryWrapper<>();
            studentGradeQueryWrapper.eq("year_part",yearPart);
            studentGradeQueryWrapper.eq("quarter_num",quarterNum);
            studentGradeQueryWrapper.ne("status",3);
            studentGradeQueryWrapper.eq("student_id",orderDetail.getStudentId());
            studentGradeQueryWrapper.orderByDesc("id");
            studentGradeQueryWrapper.last("limit 1");
            StudentGrade studentGrade = iStudentGradeService.getOne(studentGradeQueryWrapper);
            if (studentGrade!=null){
                //临时设置，春季班上课的班型
                Grade grade = iGradeService.getById(studentGrade.getGradeId());
                if (grade !=null){
                    //精英班
                    if (grade.getCourseTypeId().equals(1570701121454350337L)){
                        studentClassType.setClassTypeId(1565023758494502914L);//培优班
                        studentClassType.setClassTypeIdStr("1565023758494502914");
                    }else {
                        studentClassType.setClassTypeId(grade.getCourseTypeId());
                        studentClassType.setClassTypeIdStr(grade.getCourseTypeId().toString());
                    }
                }
            }else {
                //没有数据，为新生
                studentClassType.setClassTypeId(1575859909042028546L);//提高班
                studentClassType.setClassTypeIdStr("1575859909042028546");
            }
            //iStudentClassTypeService.save(studentClassType);
            //this.updateClassTypeOther(orderDetail,dict,quarter,lastQuarter);
        }

        iStudentClassTypeService.saveOrUpdate(studentClassType);
    }


    /**
     * 数学、物理
     * @param orderDetail
     * @param dict
     * @param quarter
     * @param lastQuarter
     */
    public void  updateClassTypeOther(OrderDetail orderDetail,Dict dict,Quarter quarter,Quarter lastQuarter){
        //1为假期（上个学期为假期）
        if (dict.getTag().equals(1)){
            //如果上个学期为假期，再获取出上个学期
            lastQuarter = iQuarterService.getLastQuarter(lastQuarter.getYearPart(),lastQuarter.getNum());
        }
        QueryWrapper<Transcript> transcriptQueryWrapper = new QueryWrapper<>();
        transcriptQueryWrapper.eq("year_part",lastQuarter.getYearPart());
        transcriptQueryWrapper.eq("quarter_num",lastQuarter.getNum());
        transcriptQueryWrapper.eq("subjects_id",orderDetail.getSubjectsId());
        transcriptQueryWrapper.eq("student_id",orderDetail.getStudentId());
        transcriptQueryWrapper.eq("is_statistics",1);
        transcriptQueryWrapper.eq("exam_num",4);//期末
        transcriptQueryWrapper.last("limit 1");
        Transcript transcript = iTranscriptService.getOne(transcriptQueryWrapper);
        Long classTypeId = 1575859909042028546L;//默认提高班
        String classTypeIdStr = "1575859909042028546";
        boolean isAt = false;

        if (transcript != null){
            isAt = true;

            BigDecimal diffScorse = null;
            String diffScorseStr = null;//分段对比值
            CourseType courseType = null;
            Integer yearClassId = orderDetail.getYearClassId();
            String score = transcript.getScore();

            //英语
            if (transcript.getSubjectsId().equals(1L)){
                if (transcript.getGradeSection().equals(0)){
                }else if (transcript.getGradeSection().equals(1)){
                    //分数类型：1分数，2分段
                    if (transcript.getScoreType().equals(1)){
                        diffScorse = new BigDecimal(90);
                    }else {
                        diffScorseStr = "A,A+";
                    }
                }else if (transcript.getGradeSection().equals(2)){
                    //分数类型：1分数，2分段
                    if (transcript.getScoreType().equals(1)){
                        diffScorse = new BigDecimal(90);
                    }else {
                        diffScorseStr = "A,A+";
                    }
                }else if (transcript.getGradeSection().equals(3)){
                    //分数类型：1分数，2分段
                    //高一秋季班统一为提高班
                    if (quarter.getNum().equals(4)&& yearClassId.equals(10)){

                    }else {
                        if (transcript.getScoreType().equals(1)){
                            diffScorse = new BigDecimal(90);
                        }else {
                            diffScorseStr = "A,A+";
                        }
                    }
                }
            }else  if (transcript.getSubjectsId().equals(2L)){
                //数学
                if (transcript.getGradeSection().equals(0)){

                }else if (transcript.getGradeSection().equals(1)){
                    //分数类型：1分数，2分段
                    if (transcript.getScoreType().equals(1)){
                        diffScorse = new BigDecimal(80);
                    }else {
                        diffScorseStr = "A,A+";
                    }
                }else if (transcript.getGradeSection().equals(2)){
                    //分数类型：1分数，2分段
                    if (transcript.getScoreType().equals(1)){
                        diffScorse = new BigDecimal(90);
                    }else {
                        diffScorseStr = "A,A+";
                    }
                }else if (transcript.getGradeSection().equals(3)){
                    //分数类型：1分数，2分段
                    //秋季班高一
                    if (quarter.getNum().equals(4) && yearClassId.equals(10)){
                    }else {
                        if (transcript.getScoreType().equals(1)){
                            diffScorse = new BigDecimal(70);
                        }else {
                            diffScorseStr = "A,A+";
                        }
                    }
                }
            }else  if (transcript.getSubjectsId().equals(3L)){
                if (transcript.getGradeSection().equals(2)){
                    if (transcript.getScoreType().equals(1)){
                        //初二秋季班第一学期
                        if (quarter.getNum().equals(4) && yearClassId.equals(8)){
                            diffScorse = new BigDecimal(84);
                        }else {
                            diffScorse = new BigDecimal(80);
                        }
                    }
                }else if (transcript.getGradeSection().equals(3)){
                    //分数类型：1分数，2分段
                    //秋季班统一为提高班
                    if (quarter.getNum().equals(4) && yearClassId.equals(10)){

                    }else {
                        if (transcript.getScoreType().equals(1)){
                            diffScorse = new BigDecimal(70);
                        }
                    }
                }
            }
            if (transcript.getScoreType().equals(1)){
                if (diffScorse !=null){

                    BigDecimal bScorese = new BigDecimal(score);
                    if (bScorese.compareTo(diffScorse)>=0){
                        //学期
                        courseType = iCourseTypeService.getNextCourseType(classTypeId,quarter.getType());
                        if (courseType!= null){
                            classTypeIdStr+=","+classTypeId;
                        }
                    }
                }
            }else {
                if (diffScorseStr != null){
                    List<String> diffScorseList = Arrays.asList(diffScorseStr.split(","));
                    if (diffScorseList.contains(score)){
                        //学期
                        courseType = iCourseTypeService.getNextCourseType(classTypeId,quarter.getType());
                        if (courseType!= null){
                            classTypeIdStr+=","+classTypeId;
                        }
                    }
                }
            }
        }

        if (isAt){
            QueryWrapper<StudentClassType> studentClassTypeQueryWrapper = new QueryWrapper<>();
            studentClassTypeQueryWrapper.eq("student_id",orderDetail.getStudentId());
            studentClassTypeQueryWrapper.eq("subjects_id",orderDetail.getSubjectsId());
            studentClassTypeQueryWrapper.eq("year_part",quarter.getYearPart());
            studentClassTypeQueryWrapper.eq("quarter_num",quarter.getNum());

            //是否已经添加过
            StudentClassType studentClassType = iStudentClassTypeService.getOne(studentClassTypeQueryWrapper);

            if (studentClassType == null){
                studentClassType = new StudentClassType();
            }

            studentClassType.setYearPart(quarter.getYearPart());
            studentClassType.setQuarterNum(quarter.getNum());
            studentClassType.setStudentId(orderDetail.getStudentId());
            studentClassType.setSubjectsId(orderDetail.getSubjectsId());
            studentClassType.setClassTypeId(classTypeId);
            studentClassType.setClassTypeIdStr(classTypeIdStr);
            studentClassType.setLastClassTypeId(0L);
            studentClassType.setRemark("");
            iStudentClassTypeService.saveOrUpdate(studentClassType);
        }
    }

}
